package com.situ.student.util;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Pagination {
    private int pageNo;//页码
    private int pageSize;//页面大小
    private long total;//总记录数
    private int pages;//总页数

    public Pagination(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    //返回查询的起始行
    public int getOffset() {
        return (pageNo - 1) * pageSize;
    }

    //查询的行数
    public int getLimit() {
        return pageSize;
    }

    //获取总页数
    public int getPages() {
        pages = (int) (total / pageSize);
        if (total % pageSize > 0) {
            pages++;
        }
        return pages;
    }
}
